package dwei.log
{
	import mx.logging.ILogger;
	import mx.logging.Log;

	public class LogMgr
	{
//============================================================================
//PROPERTY
//============================================================================
		private static var _logger:ILogger;
		private static var _target:LogTarget;
		
		public static var log:Boolean = true;
//============================================================================
//INITIALIZE
//============================================================================
		private static function init():void
		{
			_target = new LogTarget(new LogUI());
			_target.includeCategory = _target.includeDate = _target.includeLevel = _target.includeTime = true;
			Log.addTarget(_target);
			_logger = Log.getLogger("org.common.mgr.log.LogMgr");
		}
		init();
//============================================================================
//PUBLIC
//============================================================================
		public static function debug(message:String):void
		{
			if (log) _logger.debug(message);
		}
		public static function error(message:String):void
		{
			if (log) _logger.error(message);
		}
		public static function fatal(message:String):void
		{
			if (log) _logger.fatal(message);
		}
		public static function info(message:String):void
		{
			if (log) _logger.info(message);
		}
		public static function warn(message:String):void
		{
			if (log) _logger.warn(message);
		}
//============================================================================
//GETTER/SETTER
//============================================================================
		public static function set level(level:int):void
		{
			_target.level = level;
		}
		public static function set ui(value:ILogUI):void
		{
			if (value == null) return;
			_target.ui = value;
		}
		public static function get ui():ILogUI
		{
			return _target.ui;
		}
	}
}